﻿using System;
using System.Web.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Jw.Core;
using Jw.Models;
using Jw.Utils;
using Jw.Web;
using Jw.Web.Areas.Mms.Common;

namespace Jw.Controllers
{
    [AllowAnonymous]
    [MvcMenuFilter(false)]
    public class LoginController : Controller
    {
        public ActionResult Index()
        {
            return Pacm();
        }

        /// <summary>
        /// 材料管理
        /// </summary>
        /// <returns></returns>
        public ActionResult Mms()
        {
            ViewBag.CnName = "管控一体化系统";
            ViewBag.EnName = "Management-Control Integration System";
            ViewBag.EnNameStyle = "left:298px;";
            return View("Index");
        }
        /// <summary>
        /// 生产管控
        /// </summary>
        /// <returns></returns>
        public ActionResult Pacm()
        {
            ViewBag.CnName = "管控一体化系统";
            ViewBag.EnName = "Management-Control Integration System";
            ViewBag.EnNameStyle = "left:298px;";
            return View("Index");
        }
        public JsonResult DoAction(JObject request)
        {
            var message = new sys_userService().Login(request);
            return Json(message, JsonRequestBehavior.DenyGet);
        }


        /// <summary>
        /// 修改密码
        /// </summary>
        /// <param name="oldPass">原密码</param>
        /// <param name="newPass">新密码</param>
        /// <returns></returns>
        public JsonResult ChangePassword(string oldPass, string newPass)
        {
            // string userName = 
            var message = new sys_userService().ChangeUserPass(FormsAuth.GetUserData().UserCode, oldPass, newPass);
            return Json(message, JsonRequestBehavior.DenyGet);
        }


        public ActionResult Logout()
        {

            FormsAuth.SingOut();
            return Redirect("~/Login");
        }
    }
}
